import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
import javax.servlet.http.Cookie
import luckydiem.User


//dada
class LogoutController {
    def springSecurityService
    def reportService
    def index = {
        User user = springSecurityService.getCurrentUser()
        reportService.newReport("user_logout", user?.id)
        session.username = "guest"
        def cookie = new Cookie("userName", "guest")
        response.addCookie(cookie)
        if (user) {
            redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl
        }
    }
}
